import axios from "axios";
//封装网络请求
function startRequestOnly(param){
  return axios({...param}).then(res=>res.data).catch(err=>err);
} 

//封装网络请求可以用来接收多个
async function network(params){
    if(params instanceof Array){
      //定义数组存储多个数据
      let results = [];
      for(let index in params){
        let result = await startRequestOnly(params[index]);
        console.log(result);
        results.push(result);
      }
      return results; 
    }else{
      return await startRequestOnly(params);
    }
} 

//导出网络请求
export default network; 